<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<title>编辑</title>
		<link rel="stylesheet" type="text/css" href="../../plugins/layui/css/layui.css" />
		<link href="../../kitAdmin/css/app.css" rel="stylesheet" type="text/css" />
		<link rel="stylesheet" type="text/css" href="../../plugins/select2/dist/css/select2.min.css" />
	</head>

	<body>
		<div class='kit-table'>
			<div style='margin:10px'>

				<form class='layui-form' action='' lay-filter='form-edit'>
					<input type='hidden' name='id' data-link='{:id}' />
					<div class='layui-form-item'>
						<div class='layui-inline'>
							<label class='layui-form-label'>课程中文名称</label>
							<div class='layui-input-inline'>
								<input type='text' placeholder='' data-link='{:nameZh}' id='_nameZh' name='nameZh' class='layui-input'>
							</div>
						</div>
						<div class='layui-inline'>
							<label class='layui-form-label'>课程英文名称</label>
							<div class='layui-input-inline'>
								<input type='text' placeholder='' data-link='{:nameEn}' id='_nameEn' name='nameEn' class='layui-input'>
							</div>
						</div>
					</div>
					<div class='layui-form-item'>
						<div class='layui-inline'>
							<label class='layui-form-label'>课程章节介绍</label>
							<div class='layui-input-inline'>
								<input type='text' placeholder='' data-link='{:section}' id='_section' name='section' class='layui-input'>
							</div>
						</div>
						<div class='layui-inline'>
							<label class='layui-form-label'>特点介绍</label>
							<div class='layui-input-inline'>
								<input type='text' placeholder='' data-link='{:feature}' id='_feature' name='feature' class='layui-input'>
							</div>
						</div>
					</div>
					<div class='layui-form-item'>
						<div class='layui-inline'>
							<label class='layui-form-label'>封面</label>
							<div class='layui-input-inline' style="width: 280px!important; height: 200px!important;">
								<input type='hidden' placeholder=''data-link='{:cover}' id='_cover' name='cover' class='layui-input'>
								<div class="layui-upload-drag" id="test10" name="fileName">
									<img  id="cimg" src="../../common/img/default.png"/>
								  <!--<i class="layui-icon"></i>-->
								  <p>点击上传，或将文件拖拽到此处</p>
								</div>
							</div>
						</div>

					</div>

				</form>
			</div>
		</div>
		<script src="../../common/js/jquery.js" type="text/javascript" charset="utf-8"></script>
		<script src="../../static/js/base.js" type="text/javascript" charset="utf-8"></script>
		<script src="../../plugins/jsviews/jsviews.js" type="text/javascript"></script>
		<script src="../../plugins/layui/layui.js" type="text/javascript" charset="utf-8"></script>
		<script src="../../plugins/select2/dist/js/select2.min.js" type="text/javascript" charset="utf-8"></script>
		<script type="text/javascript">
			var uid = getQueryVariable('id');
			jQuery(document).ready(function() {
				bindFormData();
			});
			var callback_save = function() {
				return $('.layui-form').serialize();
			}

			function bindFormData() {
				if(uid) {
					$.ajax({
						url:baseUrl+ '/lessons/' + uid,
						type: 'get',
						success: function(data) {
							$.link(true, ".kit-table", data.data);
							$('select').select2().change();
							if(data.data.cover){
								$('#cimg').attr('src', "../.."+data.data.cover);
							}
						},
						error: function() {
							parent.layer.alert('系统或网络错误！');
						}
					});
				}
			}

			//***初始化上传插件
			layui.use('upload', function() {
				var $ = layui.jquery,
					upload = layui.upload;

				//拖拽上传
				upload.render({
					elem: '#test10',
					url:baseUrl+ '/upload/cover',
					field:'file',
					accept:'images',
//					auto: false,//false不自动上传
					done: function(res) {
						$('#_cover').val(res.data);
						$('#cimg').attr('src', "../.."+res.data);
					}
				});

			});
		</script>
	</body>

</html>